const httpServersLive = (url, method, data) => {
	// var interfaceUrl='https://tapi.bkyh.top/';   https://tbpapi.jinghushi.com/
	var interfaceUrl = 'https://chat.ceshisss.top/api/';
	var token =uni.getStorageSync('token')||'';

	let httpDefaultOpts = {
		url: interfaceUrl + url,
		data: data,
		method: method,
		header: {
			// 'Content-Type': 'application/x-www-form-urlencoded',
			'token': token,
		},
		// dataType: 'json',
	}
	let promise = new Promise(function(resolve, reject) {
		uni.request(httpDefaultOpts).then(
			(res) => {
				// let s=res[1].data.code.toString()[0]
				if(res[1].data.code == 401||res[1].data.code == 402||res[1].data.code == 403){
					var Ver = uni.getStorageSync('ver');
					var Lng = uni.getStorageSync('x');
					var Lat = uni.getStorageSync('y');
					var TuanIDstr = uni.getStorageSync('JPinTuan');
					uni.clearStorage();
					uni.setStorageSync('mid', res[1].data.data.mid);
					uni.setStorageSync('JPinTuan', TuanIDstr);
					uni.setStorageSync('ver', Ver);
					uni.setStorageSync('x',Lng);
					uni.setStorageSync('y',Lat);
					uni.reLaunch({
						url: '/pages/public/login?mid=' + res[1].data.data.mid
					})
				}
				resolve(res[1].data)
			}
		).catch(
			(response) => {
				reject(response)
			}
		)
	})
	return promise
}

export default httpServersLive